package controllers

import (
	"fmt"
	beego "github.com/beego/beego/v2/server/web"
	"github.com/gorilla/websocket"
	"net/http"
	"user/utils"
)

type RecoverGbController struct {
	beego.Controller
}

func (c *RecoverGbController) RecoverGb() {
	conn, err := (&websocket.Upgrader{
		ReadBufferSize:  1024,
		WriteBufferSize: 1024,
		CheckOrigin: func(r *http.Request) bool {
			return true
		},
		EnableCompression: false,
	}).Upgrade(c.Ctx.ResponseWriter, c.Ctx.Request, nil)
	if err != nil {
		fmt.Println("websocket连接失败")
	}
	userid := c.GetString("userid")
	rabbit := utils.NewRabbitMQPubSub("" + "Gb")
	rabbit.RecieveSub(userid, conn)
}
